package com.easy.auth.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.easy.auth.domain.Department;
import com.easy.auth.service.DepartmentService;
import com.easy.base.service.impl.EManagerImpl;
import com.easy.common.web.PagedList;

@Service
public class DepartmentServiceImpl extends EManagerImpl<Department> implements
		DepartmentService {

	@Override
	public PagedList<Department> getAllDepartments() {
		List<Department> departmentList = super.findList(new Department());
		return new PagedList<Department>(departmentList);
	}

	@Override
	public int saveDepartment(Department department) {
		return super.saveOrEdit(department);
	}

	@Override
	public Department findDepartmentById(Department department) {
		return super.findByOid(department);
	}

	@Override
	public int removeDepartments(String[] oids) {
		List<Department> deptlist = new ArrayList<Department>();
		for (String oid : oids) {
			Department department = new Department();
			department.setOid(oid);
			deptlist.add(department);
		}
		return super.removeAll(deptlist);
	}
}